package com.atguigu.tingshu.dispatch.config;

import com.xxl.job.core.executor.impl.XxlJobSpringExecutor;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * Author  王东剑
 * Created on 26/6/2024 PM4:40
 * Package_name com.atguigu.tingshu.dispatch.config
 * Description
 */
@Configuration
@Slf4j
@ConfigurationProperties(prefix = "xxl.job")
@Data
public class DispatchJobHandlerConfig {
	private String addresses;
	private String accessToken;
	private String appName;
	private String ip;
	private Integer port;
	@Bean
	public XxlJobSpringExecutor xxlJobExecutor() {
		log.info(">>>>>>>>>>> xxl-job config init.");
		XxlJobSpringExecutor xxlJobSpringExecutor = new XxlJobSpringExecutor();
		xxlJobSpringExecutor.setAdminAddresses(addresses);
		xxlJobSpringExecutor.setAppname(appName);
		xxlJobSpringExecutor.setIp(ip);
		xxlJobSpringExecutor.setPort(port);
		xxlJobSpringExecutor.setAccessToken(accessToken);
		return xxlJobSpringExecutor;
	}
}
